package com.liqing.movecomment.util;

import com.alibaba.ttl.TransmittableThreadLocal;

import java.util.Objects;


public class ThreadLocalUtils {

    //private static ThreadLocal<Map<Object, Object>> RESOURCES = ThreadLocal.withInitial(() -> new HashMap<>());
    private static ThreadLocal<Object> RESOURCES = new TransmittableThreadLocal();


    public static void removeResources() {
        if (Objects.nonNull(RESOURCES)) {
            RESOURCES.remove();
        }
    }


    public static void put(Object key, Object value) {
        Objects.requireNonNull(key, "key不能为空");

        RESOURCES.set(value);
    }

    public static Object get() {
        return RESOURCES.get();
    }


//    public static Object remove(Object key) {
//        return Objects.isNull(getResources()) ? null : getResources().remove(key);
//    }

}
